<template>
  <NavBar>
    <div slot="left" class="nave-left" @click="detailBack"><img src="~assets/img/common/back.svg" alt=""></div>
    <div slot="center" class="center">
      <div v-for="(item,index) in titles"
           class="center-titles"
           @click="titlesClick(index)"
           :class="{active:index===currentIndex}"
      >
        {{ item }}
      </div>
    </div>
  </NavBar>
</template>

<script>
import NavBar from "../../../components/common/navbar/NavBar";

export default {
  name: "DetailNavBar",
  components: {
    NavBar
  },
  data() {
    return {
      titles: ['商品', '参数', '评论', '推荐'],
      currentIndex: 0
    }
  },
  methods: {
    titlesClick(index) {
      this.currentIndex = index;
      this.$emit("titlesClick", index)
    },
    detailBack() {
      this.$router.back()
    }
  }
}
</script>

<style scoped>
.center {
  display: flex;
}

.center-titles {
  flex: 1;
}

.nave-left {
  margin-top: 5px;
}

.active {
  color: var(--color-high-text);
}
</style>